package org.example.authservice.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.authservice.pojo.UserRole;

/**
 * @author lj20050120
 */
@Mapper
public interface UserRoleMapper extends BaseMapper<UserRole> {
    /**
     * 判断用户是否有指定角色
     * @param userId 用户ID
     * @param roleId 角色ID
     * @return true：有指定角色；false：没有指定角色
     */
    @Select("SELECT COUNT(*) FROM user_role WHERE user_id = #{userId} AND role_id = #{roleId}")
    boolean existsByUserIdAndRoleId(@Param("userId") Integer userId, @Param("roleId") Integer roleId);
}
